import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '培训班名称',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '年度',
    align:"center",
    dataIndex: 'year'
  },
  {
    title: '培训类别',
    align:"center",
    dataIndex: 'contractorTrainType_dictText'
  },
  {
    title: '培训开始日期',
    align:"center",
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '培训结束日期',
    align:"center",
    dataIndex: 'endDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '实际培训学时',
    align:"center",
    dataIndex: 'creditHour'
  },
  {
    title: '授课人',
    align:"center",
    dataIndex: 'lecturer'
  },
  {
    title: '是否外部单位培训',
    align:"center",
    dataIndex: 'externalTrainingOrNot_dictText'
  },
  {
    title: '培训单位',
    align:"center",
    dataIndex: 'trainingCompany'
  },
  {
    title: '培训形式',
    align:"center",
    dataIndex: 'trainingForm_dictText'
  },
  {
    title: '培训人数',
    align:"center",
    dataIndex: 'traineesNumber'
  },
  {
    title: '合格人数',
    align:"center",
    dataIndex: 'qualifiedNumber'
  },
  {
    title: '培训内容',
    align:"center",
    dataIndex: 'trainingContent'
  },
  {
    title: '培训效果/总结',
    align:"center",
    dataIndex: 'trainingEffect'
  },
  {
    title: '考试/考核方式',
    align:"center",
    dataIndex: 'assessmentMethod'
  },
  {
    title: ' 培训教材/试题',
    align:"center",
    dataIndex: 'trainingMaterial',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "培训班名称",
    field: "name",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "培训类别",
    field: "contractorTrainType",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorTrainType"
    },
    //colProps: {span: 6},
  },
  {
    label: "是否外部单位培训",
    field: "externalTrainingOrNot",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
    //colProps: {span: 6},
  },
  {
    label: "培训形式",
    field: "trainingForm",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorTrainingForm"
    },
    //colProps: {span: 6},
  },
  {
    label: "培训内容",
    field: "trainingContent",
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '培训班名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入培训班名称!'},
      ];
     },
  },
  {
    label: '年度',
    field: 'year',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入年度!'},
      ];
     },
  },
  {
    label: '培训类别',
    field: 'contractorTrainType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorTrainType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入培训类别!'},
      ];
     },
  },
  {
    label: '培训开始日期',
    field: 'startDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入培训开始日期!'},
      ];
     },
  },
  {
    label: '培训结束日期',
    field: 'endDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入培训结束日期!'},
      ];
     },
  },
  {
    label: '实际培训学时',
    field: 'creditHour',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入实际培训学时!'},
      ];
     },
  },
  {
    label: '授课人',
    field: 'lecturer',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入授课人!'},
      ];
     },
  },
  {
    label: '是否外部单位培训',
    field: 'externalTrainingOrNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入是否外部单位培训!'},
      ];
     },
  },
  {
    label: '培训单位',
    field: 'trainingCompany',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入培训单位!'},
      ];
     },
  },
  {
    label: '培训形式',
    field: 'trainingForm',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorTrainingForm"
    },
  },
  {
    label: '培训人数',
    field: 'traineesNumber',
    component: 'InputNumber',
    dynamicDisabled:true,
  },
  {
    label: '合格人数',
    field: 'qualifiedNumber',
    component: 'InputNumber',
    dynamicDisabled:true,
  },
  {
    label: '培训内容',
    field: 'trainingContent',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  {
    label: '培训效果/总结',
    field: 'trainingEffect',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  {
    label: '考试/考核方式',
    field: 'assessmentMethod',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  {
    label: ' 培训教材/试题',
    field: 'trainingMaterial',
    component: 'JUpload',
    componentProps:{
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbContractorEducationTrainingTrainedPersonnelColumns: BasicColumn[] = [
  {
    title: '姓名',
    align:"center",
    sorter: true,
    dataIndex: 'contractorPersonnelId'
  },
  {
    title: '身份证号',
    align:"center",
    sorter: true,
    dataIndex: 'idCard'
  },
  {
    title: '年龄',
    align:"center",
    sorter: true,
    dataIndex: 'age'
  },
  {
    title: '成绩',
    align:"center",
    dataIndex: 'grade'
  },
  {
    title: '是否合格',
    align:"center",
    sorter: true,
    dataIndex: 'isStandard_dictText'
  },
  {
    title: '证书编号',
    align:"center",
    sorter: true,
    dataIndex: 'number'
  },
  {
    title: '作业有效期限',
    align:"center",
    sorter: true,
    dataIndex: 'validityPeriod',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
];
//子表表单数据
export const tbContractorEducationTrainingTrainedPersonnelFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '姓名',
    field: 'contractorPersonnelId',
    component: 'Input',
  },
  {
    label: '身份证号',
    field: 'idCard',
    component: 'Input',
  },
  {
    label: '年龄',
    field: 'age',
    component: 'InputNumber',
  },
  {
    label: '成绩',
    field: 'grade',
    component: 'InputNumber',
  },
  {
    label: '是否合格',
    field: 'isStandard',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
  },
  {
    label: '证书编号',
    field: 'number',
    component: 'Input',
  },
  {
    label: '作业有效期限',
    field: 'validityPeriod',
    component: 'DatePicker',
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '培训班名称',order: 0,view: 'text', type: 'string',},
  year: {title: '年度',order: 1,view: 'text', type: 'string',},
  contractorTrainType: {title: '培训类别',order: 2,view: 'list', type: 'string',dictCode: 'contractorTrainType',},
  startDate: {title: '培训开始日期',order: 3,view: 'date', type: 'string',},
  endDate: {title: '培训结束日期',order: 4,view: 'date', type: 'string',},
  creditHour: {title: '实际培训学时',order: 5,view: 'number', type: 'number',},
  lecturer: {title: '授课人',order: 6,view: 'text', type: 'string',},
  externalTrainingOrNot: {title: '是否外部单位培训',order: 7,view: 'radio', type: 'string',},
  trainingCompany: {title: '培训单位',order: 8,view: 'text', type: 'string',},
  trainingForm: {title: '培训形式',order: 9,view: 'radio', type: 'string',},
  traineesNumber: {title: '培训人数',order: 10,view: 'number', type: 'number',},
  qualifiedNumber: {title: '合格人数',order: 11,view: 'number', type: 'number',},
  trainingContent: {title: '培训内容',order: 12,view: 'textarea', type: 'string',},
  trainingEffect: {title: '培训效果/总结',order: 13,view: 'textarea', type: 'string',},
  assessmentMethod: {title: '考试/考核方式',order: 14,view: 'textarea', type: 'string',},
  trainingMaterial: {title: ' 培训教材/试题',order: 15,view: 'file', type: 'string',},
};
